#include"kernel/types.h"
#include"user/user.h"
#include"kernel/fcntl.h"
int main(int argc ,const char *argv[]){
    int pid,signal,child=0;
    char *ch[]={"echo","This","Is","ECHO"};
    pid=fork();    
    if(pid==0){
	    close(1);
	    open("output.txt",O_WRONLY | O_CREATE);
        if(argc!=1){
            sleep(10);
            printf("fork() returned %d\n",pid);
        }
        else{
		    child=exec("echo",ch);
        }
        printf("child\n");
	    printf("exec failed!\n");
    }else{
        printf("fork() returned %d\n",pid);
        printf("parent\n");
        if(child);
        else printf("child proc success\n");
	    printf("Process %d ended\t",wait(&signal));
	    printf("with code %d\n",signal);
    }
    exit(0);
}
